<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
         
        <ui:define name="content">
             <br />
            
            <p:panel header="Material Requirement Plans" id="MRP" toggleable="true">
                <h:form prependId="false">
                    <h:panelGroup id="messagePanel" layout="block">
                        <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                    </h:panelGroup>
                   
                    <h:panelGroup rendered="#{rawMaterialRequirementWeeklyEntityController.allMRPsByMonth.size() > 0}">
                        <p:dataTable value="#{rawMaterialRequirementWeeklyEntityController.allMRPsByMonth}" var="item" 
                                       style="text-align: center"
                                     paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15"
                                      >
                            <p:column filterBy="#{item.yearOfProduction}">
                                <f:facet name="header">
                                    <h:outputText value="Year"/>
                                </f:facet>
                                <h:outputText value="#{item.yearOfProduction}"/>
                            </p:column>      
                            
                            <p:column  filterBy="#{item.monthOfProduction}">
                                <f:facet name="header">
                                    <h:outputText value="Month"/>
                                </f:facet>
                                <h:outputText value="#{item.monthOfProduction}"/>
                            </p:column> 
                            
<!--                             <p:column filterBy="#{item.weekOfProduction}">
                                <f:facet name="header">
                                    <h:outputText value="Week"/>
                                </f:facet>
                                <h:outputText value="#{item.weekOfProduction}"/>
                            </p:column>
                            
                            <p:column filterBy="#{item.rawMaterial.productName}">
                                <f:facet name="header">
                                    <h:outputText value="Raw Material"/>
                                </f:facet>
                                <h:outputText value="#{item.rawMaterial.productName}"/>
                            </p:column>-->
                            
                           <p:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            
                               
                               <p:menuButton value="Options" >
                                     <p:menuitem value=" View" ajax="false" icon="ui-icon ui-icon-search" 
                                                action="#{rawMaterialRequirementWeeklyEntityController.listMrpsThisMonth(item)}" rendered="#{item.archived==false and loginBacking.listMRPS}"/>  
                               
                                     <p:menuitem value=" Delete" ajax="false" rendered="#{item.archived==false and loginBacking.deleteMRP}" icon="ui-icon ui-icon-close"
                                                action="#{rawMaterialRequirementWeeklyEntityController.deleteMrpMonth(item)}"/> 
                                </p:menuButton>
                        </p:column>
                           
                        </p:dataTable>   
                    </h:panelGroup>
                    <br />
                </h:form>
            </p:panel>
            <h:form>
            <p:commandButton rendered="#{loginBacking.createNewMRP}" action="#{rawMaterialRequirementWeeklyEntityController.prepareCreate}" ajax="false" value="Create New Material Requirement Plan"/>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
